//
//  MyNavigationViewController.m
//  CoolRollerSkating
//
//  Created by 谢伟康 on 15/11/9.
//  Copyright © 2015年 Coollang. All rights reserved.
//

#import "MyNavigationViewController.h"
#import "UIColor+Extension.h"

@interface MyNavigationViewController ()

@end

@implementation MyNavigationViewController

+ (void)initialize {
    // 判断如果是当前的类(非子类)，才调用方法
    if (self == [MyNavigationViewController class]) {
        [self customizeAppearance];
    }
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self updateThemeUI];
    self.interactivePopGestureRecognizer.enabled = NO;
}

// 设置屏幕方向
- (BOOL)shouldAutorotate{
    //是否支持旋转屏幕
    return YES;
}
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskPortrait; //支持哪些方向
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
    //默认显示的方向
    return UIInterfaceOrientationPortrait;
}

+ (void)customizeAppearance
{
    [[UINavigationBar appearance] setTranslucent:NO];
    [[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
    
    CGFloat textFont = 20.0f;
    
    if ([NSBundle currentLangeuage] == kLanguageFrennch) {
        textFont = 16.0f;
    }
    
    [[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor whiteColor],
                                                           NSFontAttributeName: [UIFont systemFontOfSize:textFont]
                                                           }];
    [[UINavigationBar appearance] setBackgroundColor:kSelectedColor];
    [[UINavigationBar appearance] setBarTintColor:kSelectedColor];
    [[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];
    
    //与下面等效
    [[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: kUnSelectedColor} forState:UIControlStateNormal];
    [[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:  kSelectedColor} forState:UIControlStateSelected];
    [[UITabBar appearance] setTranslucent:NO];
}

#pragma mark - Private Method
- (void)updateThemeUI
{
    self.view.backgroundColor = [UIColor colorWithHex:0xf7f7f7 alpha:1.0];
    [self.navigationBar setBackgroundImage:[UIImage imageNamed:@"nav_icon_background"] forBarMetrics:UIBarMetricsDefault];
}

//- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
//    // 设置push的时候隐藏tabbar
//    viewController.hidesBottomBarWhenPushed = YES;
//    [super pushViewController:viewController animated:animated];
//}

@end
